//
//  UIButton+Extension.swift
//  WeiBo2017
//
//  Created by 王璐 on 2017/4/19.
//  Copyright © 2017年 wl. All rights reserved.
//

import UIKit

extension UIButton{
    
    convenience init(
        title:String?,
        fontSize:CGFloat = 17,
        color:UIColor = UIColor.darkGray,
        imageName:String?=nil,
        backgroudImageName:String?=nil){
        
        self.init()
        
        self.setTitle(title, for: .normal)
        self.setTitleColor(color, for: .normal)
        
        if let imageName = imageName{
            self.setImage(UIImage(named:imageName), for: .normal)
            self.setImage(UIImage(named:imageName + "highlighted"), for: .highlighted)
        }
        if let backgroudImageName = backgroudImageName{
            self.setBackgroundImage(UIImage(
                named:backgroudImageName), for: .normal)
            self.setBackgroundImage(UIImage(named:backgroudImageName + "highlighted"), for: .highlighted)
        }
       
        sizeToFit()
    }
    
}
